//https://leetcode.cn/problems/backspace-string-compare/description/
class Solution {
public:
    bool backspaceCompare(string s, string t) {
        string str1, str2;
        for (auto tmp : s)
        {
            if (str1.empty() && tmp == '#')continue;
            if (tmp == '#')str1.pop_back();
            else str1 += tmp;
        }
        for (auto tmp : t)
        {
            if (str2.empty() && tmp == '#')continue;
            if (tmp == '#')str2.pop_back();
            else str2 += tmp;
        }
        return str1 == str2;
    }
};